#ifndef __CH423_H__
#define __CH423_H__

#include "esp_err.h"
#include "driver/i2c.h"
#include "i2c_custom.h"

#define CH423_DEBUG 0

#define CH423_WR_SET (0x48 >> 1) /*!< CH423_WR_SET cmd*/
#define CH423_WR_OCL (0x44 >> 1) /*!< CH423_WR_OCL cmd*/
#define CH423_WR_OCH (0x46 >> 1) /*!< CH423_WR_OCH cmd*/
#define CH423_RD_IO (0x4D >> 1)  /*!< CH423_RD_IO cmd*/

#define CH423_NVS_NAME "CH423"
#define CH423_NVS_OC_L_KEY "CH423_OC_L"

#ifdef __cplusplus
extern "C"
{
#endif

    typedef enum
    {
        OC_L_0,
        OC_L_1,
        OC_L_2,
        OC_L_3,
        OC_L_4,
        OC_L_5,
        OC_L_6,
        OC_L_7,
    } ch423_oc_l_enmu;

    typedef struct
    {
        uint8_t ch423_oc; /*!< ch423_oc data*/
        uint8_t ch423_io; /*!< ch423_io data*/
    } ch423_io_oc;

    void ch423_set_oc_level(ch423_oc_l_enmu ch423_oc_pin, bool level);
    uint8_t ch423_get_io_data(void);
    uint8_t ch423_get_open_num_data(void);
    void ch423_task(void *arg);

#ifdef __cplusplus
}
#endif

#endif
